<?php
require_once "../includes/config.php";
require_once "../includes/functions.php";
require_once('../AmazonAPI/.config.inc.php');
require_once('../AmazonAPI/CBUI/CBUIMultiUsePipeline.php');
session_start();
$sessid=session_id();
$amount=0;

//arrays
$recipient_token_arr = array();
$recipient_amount_arr = array();
$user_id_arr = array();

$recipient_token_arr = $_POST['recipient_token_arr'];
$recipient_amount_arr = $_POST['recipient_amount_arr'];
$user_id_arr = $_POST['user_id_arr'];
//print_r($user_id_arr);

$_SESSION['recipient_tokens'] = $recipient_token_arr;
$_SESSION['recipient_amounts'] = $recipient_amount_arr;
$_SESSION['user_id_arr'] = $user_id_arr;

$amount=number_format(array_sum($recipient_amount_arr),2);

$pipeline = new Amazon_FPS_CBUIMultiUsePipeline(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY);

$pipeline->setMandatoryParameters("swapen".rand(),  
		H_ROOT."admin/process_amazon.php", $amount);
		
$pipeline->setRecipientTokenList(false, $recipient_token_arr);

//optional parameters
$pipeline->addParameter("paymentMethod", "CC,ABT,ACH");
$re_URL = $pipeline->getUrl();
header("location:".$re_URL);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Swapen.com - Buy and Sell</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style2 {color:#fefefe; font-size:12px; font-family: "Trebuchet MS"; background-color:#000000;}
.style3 {font-size:14px; color: #4a4a4a; font-family: "Trebuchet MS";}
-->
</style>

</head>

<body>
<div align="center" class="style1"><span class="style2">Please wait, you are being redirected to selected payment gateway</span><span class="style3">.</span></div>

</body>
</html>
